package com.zhipu.hydration.utils;

import android.view.Gravity;

import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.zhipu.hydration.BaseApplication;
import com.zhipu.hydration.R;
import com.zhipu.hydration.common.Constants;
import com.zhipu.hydration.utils.serialport.KeySerialPortUtils;

public class InitializeUtils {
    /**
     *  上下文
     */
    private static BaseApplication MBaseApplication;
    public static BaseApplication getMBaseApplication() {
        return MBaseApplication;
    }
    public static void setMBaseApplication(BaseApplication MBaseApplication) {
        InitializeUtils.MBaseApplication = MBaseApplication;
    }



    /**
     * Toast设置统一样式
     */
    private static ToastUtils defaultMaker;
    public static ToastUtils getDefaultMaker() {
        return defaultMaker;
    }
    public static void initDefaultMaker() {
        defaultMaker = ToastUtils.getDefaultMaker();
        defaultMaker.setBgColor(ColorUtils.getColor(R.color.color_recognize_success));
        defaultMaker.setGravity(Gravity.TOP,0,400);
        defaultMaker.setTextColor(ColorUtils.getColor(R.color.color_FFFFFF));
        defaultMaker.setTextSize(26);
    }




    /**
     * 日志相关
     */
    public static void initializeLogUtils(){
        LogUtils.Config config = LogUtils.getConfig();
        //设置 log 总开关
        config.setLogSwitch(true);
        //设置 log 文件开关
        config.setLog2FileSwitch(true);
        //设置 log 可保留天数
        config.setSaveDays(5);
        // 设置 log 文件存储目录
        config.setDir(Constants.LogPath);
    }

    /**
     * 串口初始化
     */
    public static void  initializationSerialPort(){
        /**
         * 按键串口
         */
        KeySerialPortUtils.InitializeKeySerialPort();
    }

}
